Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

CHECK POLYGON IS VALID

#PROBLEM : 'ValueError: A LinearRing must have at least 3 coordinate tuples'

#Read data
collection = list(fiona.open(layer_file,'r'))
df1 = pd.DataFrame(collection)

#Check Geometry
def isvalid(geom):
    try:
        shape(geom)
        return 1
    except:
        return 0
df1['isvalid'] = df1['geometry'].apply(lambda x: isvalid(x))
df1 = df1[df1['isvalid'] == 1]
collection = json.loads(df1.to_json(orient='records'))

#Convert to geodataframe
gdf = gpd.GeoDataFrame.from_features(collection)
Comment

PREVIOUS NEXT
Code Example
Python :: python jupyter show cell execution progress bar 
Python :: run flask in Jython 
Python :: transfer learning in python with custom dataset 
Python :: Elasticsearch scroll with Parallelism r 
Python :: move python file 
Python :: How to find text of h2 tag in python requests-html 
Python :: Python NumPy squeeze function Example with axis 
Python :: Python NumPy atleast_1d Function Example 
Python :: Python NumPy copyto function example copy elements from a source array to a destination array. 
Python :: df create dummy from multiple category 
Python :: how to extract a list of values from numpy array using index list 
Python :: Python NumPy asfortranarray Function Syntax 
Python :: Python NumPy vstack Function Example with 2d array 
Python :: percentile of a score python 
Python :: pymel layout 
Python :: codeforces problem 580A 
Python :: how to fetch limited rows in pandas dataframe using sqlalchemy 
Python :: del mutiple indexes at once 
Python :: NumPy right_shift Syntax 
Python :: Break up long line of code to span over several lines 
Python :: how to take input as an integer in python 
Python :: how to initialize a token spacy python 
Python :: knn compute_distances_one_loop 
Python :: python selectionsort 
Python :: ternary operator in list comprehension python 
Python :: how do i add two matrix and store it in a list in python 
Python :: how to map url with usernames prefixed 
Python :: how to import grades into a text file in python 
Python :: sns.kdeplot make line more detailed 
Python :: ring get a list of functions names written in the Ring language 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =