mbloch/mapshaper

Join "Unable to export object-type data, writing null values"

2803media opened this issue · 3 comments

Hi

I have the following command:

mapshaper test.shp \
	-join PM_010.csv keys='id,id' calc='data = collect("Groupe personne"), COUNT = count()' \
	-filter 'COUNT > 0' \
	-o out2.shp

With the CSV file like that:

Département,CODGEO,Nom Commune,parcelle,adresse,Contenance,Nature culture,Code droit,SIREN,Groupe personne,Forme juridique,Forme juridique abrégée,Dénomination
01,01001,L'ABERGEMENT-CLEMENCIAT,010010000017,CHAMP MACONNAIS,000000120,BS,P,U21651623,0,9900,AUPM,PROPRIETAIRES DU BND 001 A0017
01,01001,L'ABERGEMENT-CLEMENCIAT,010010000A0017,CHAMP MACONNAIS,000000120,BS,P,U21651623,0,9900,AUPM,PROPRIETAIRES DU BND 001 A0017
01,01001,L'ABERGEMENT-CLEMENCIAT,010010000A0017,CHAMP MACONNAIS,000000120,BS,P,U21651623,0,9900,AUPM,PROPRIETAIRES DU BND 001 A0017
01,01001,L'ABERGEMENT-CLEMENCIAT,010010000A0018,CHAMP MACONNAIS,000000060,BS,P,U21651730,0,9900,AUPM,PROPRIETAIRES DU BND 001 A0018

But I got this error:

[join] Auto-detected number fields: Département, CODGEO, Contenance, Groupe personne, Forme juridique
[join] Joined data from 285,993 source records to 239,477 target records
[join] 1119191 target records received no data
[join] 3217/289210 source records could not be joined
[join] 32725/1358668 target records were matched by multiple source records (many-to-one relationship)
[filter] Retained 239,477 of 1,358,668 features
[o] [data] Unable to export object-type data, writing null values

I don't know why there is a "Unable to export object-type data, writing null values" error on this?

Any idea?

Thanks in advance!

The problem exist with the SHP output but is not present with the JSON output. Is this a shapefile limitation?

mbloch commented

Hi, yes, this is a Shapefile limitation. The expression data = collect("Groupe personne") creates a field named "data" containing arrays of integers (in this case). GeoJSON supports array data but Shapefile doesn't. You could use another command to transform the arrays to strings, for example:

-each 'groups = JSON.stringify(data)'

Also, you need to change data = collect("Groupe personne") to data = collect(d["Groupe personne"]) for the command to work correctly (see issue #592)

Thanks for the proposition !