I am working on a bunch of shapefile data, and I need to process it and after some kind of processing, I need to feed the data to an indexer (in this case ElasticSearch). The problem is I just discovered that there are some anomalies in the data. I found this in one of my polygons.

[(593.0587471450001, -1.8046608309999783),
 (593.0587471160001, -1.8046608379999611),
 (593.0587470810001, -1.804660872999932),

Now correct me if I am wrong, but aren't longitudes suposed to be in the range of -180 to 180 and latitudes in the range of -90 to 90? So the numbers above just don't make sense. Is there any function in shapely, GeoPandas or any other library that can validate/check whether a coordinate is valid or not? Or should I do that manually?


<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich

Also I don't know if this is relevant, but I only found this one polygon with very big numbers in it. The other polygons in the same file are fine (in the right range).

  • @user2856 That's the first time I have ever heard of projected coordinates. I am so new in this. Thanks. I updated my question with the information from the .crs attribute. – catris25 May 28 at 3:38
  • It might help to think about how these coordinates were generated. If they were produced by some automated process, it's possible they're just not properly wrapped and you might be able to correct it with a simple script, e.g., by subtracting 360. – Rob Skelly Jun 28 at 20:40

use crs attribute, for example

x = gpd.read_file("your_shapefile.shp")
coord = x.crs

there should be an EPSG value, and that is your coordinate system.
according to this right here what you need to do about your over 180 degrees coordinate value is to subtract/add it by 360 until it is in the range of -180 and 180 degrees.

to verify if your data is correct, you might want another shapefile, that you know that the shapefile is in good projection quality, as your orientation and overlay/subplot them.

#read trusted good quality shapefile for orientation
verif = gpd.read_file("orientation_shapefile.shp")

#plot the layers
base = x.plot()
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.