Shapefile.jl icon indicating copy to clipboard operation
Shapefile.jl copied to clipboard

subset shp while preserve proj

Open kongdd opened this issue 1 year ago • 1 comments

using Shapefile
import Shapefile: getshp, getdbf
using DataFrames

f = "./test/shapelib_testcases/test.shp"
t = Shapefile.Table(f)
d = DataFrame(t) 

inds = ismissing(d.TestInt)
d2 = d[inds, :] # use DataFrame, proj will be dropped

Shapefile.write(d2, "a.shp")

Any method to subset shp directly via Shapefile?

kongdd avatar Jun 20 '24 04:06 kongdd

You can use the crs keyword to write

(we do want to retain the crs in DataAPI metadata as a general GeoInterface pattern, but no one has implemented it yet)

rafaqz avatar Jun 20 '24 09:06 rafaqz