I was curious why clipping shapefiles was just so difficult and whether it was different to intersecting shapefiles?
You will see from one my questions that I gave up trying to clip a polyline with a polygon (here)
I tried various different methods:
ogr2ogr
import subprocesssubprocess.call(["C:\Program Files\GDAL\ogr2ogr", "-f", "ESRI Shapefile", "-clipsrc", clipping_shp, output_shp, input_shp])print('Done!')pyclipper
solution = pc.Execute2(pyclipper.CT_INTERSECTION, pyclipper.PFT_NONZERO, pyclipper.PFT_NONZERO)Then in R I tried:
-gIntersection(x,y, byid=TRUE, drop_lower_td=TRUE)
-gDifference
-custom gClip command I found online
However with a large polylines shapefile (around 500mb) and a very small polygon shapefile (1mb) the intersection would take a day. This led me to think perhaps I am doing something incredibly stupid and there is a quick clip command?
For example, in arcGIS the intersection command takes a few seconds so surely clipping is even easier? I know very little about GIS but to me it seems as simple as aligning the two layers by one coordinate (assuming same projection) and then selecting the outside of the clipper shape (e.g. in paint) and just deleting it from the other layer. I guess obviously this isn't the case ..
Thanks very much
أكثر...
You will see from one my questions that I gave up trying to clip a polyline with a polygon (here)
I tried various different methods:
ogr2ogr
import subprocesssubprocess.call(["C:\Program Files\GDAL\ogr2ogr", "-f", "ESRI Shapefile", "-clipsrc", clipping_shp, output_shp, input_shp])print('Done!')pyclipper
solution = pc.Execute2(pyclipper.CT_INTERSECTION, pyclipper.PFT_NONZERO, pyclipper.PFT_NONZERO)Then in R I tried:
-gIntersection(x,y, byid=TRUE, drop_lower_td=TRUE)
-gDifference
-custom gClip command I found online
However with a large polylines shapefile (around 500mb) and a very small polygon shapefile (1mb) the intersection would take a day. This led me to think perhaps I am doing something incredibly stupid and there is a quick clip command?
For example, in arcGIS the intersection command takes a few seconds so surely clipping is even easier? I know very little about GIS but to me it seems as simple as aligning the two layers by one coordinate (assuming same projection) and then selecting the outside of the clipper shape (e.g. in paint) and just deleting it from the other layer. I guess obviously this isn't the case ..
Thanks very much
أكثر...