Closed xinaesthete closed 3 years ago
I see that you do have dbase::Record
read from dbf
, I think I'm on the right track now (a bit spoiled by shapefile.js
being able to parse a zip directly, combining these elements appropriately).
Hello,
In shapefile-rs, to access the properties associated to a geometry you first have to use Reader::iter_shapes_and_records to get an iterator that gives you both the shape
(aka the geometry) and the record
(aka the properties).
The record will be a hashmap that maps String to Values that you can use to get the values you want
Indeed, I think I'd even looked at the method you mentioned before posting my initial message and then somehow it slipped my mind again. Many thanks for your help.
Having the ability to read a shapefile directly from a zipfile could be a nice extra-feature, I'll look into adding that
For now as a Rust-learning-exercise I'm fairly impressed by how easily opening a zip archive and processing the contents through your library is going with just a couple of extra lines of code, but it seems like it'd make sense for you to incorporate in a more comprehensive way to the library if you have time.
I'm very new to Rust (somewhat experienced with GIS but it's not my main background), so apologies if there's something I just failed to grok properly.
I'm trying to read shapefiles with contour lines (from the Ordanance Survey Terr50 data FWIW), which are grouped into features with 2d coordinates and a
'PROP_VALUE'
indicating the height of each line. I've previously been using https://github.com/calvinmetcalf/shapefile-js and wanted to experiment with porting that code to Rust / WASM.In the context of
shapefile.js
, they parse the results into GeoJSONFeatureCollection
, where eachFeature
has, in addition to geometry, a set of arbitrary properties indexed by string. So I access the height withfeature.properties['PROP_VALUE']
.Reading through your documentation and code, I don't think I see anyway to do the equivalent with shapefile-rs, so I guess it's just a missing feature, but I could well have missed something.