Skip to content

Commit

Permalink
Merge pull request #3 from acep-uaf/bugfix/double-nested-json
Browse files Browse the repository at this point in the history
remove double-nested properties in geojson
  • Loading branch information
ianalexmac authored May 17, 2024
2 parents a76cc7a + 68b952f commit 3ab8428
Show file tree
Hide file tree
Showing 3 changed files with 7,718 additions and 10,522 deletions.
12 changes: 6 additions & 6 deletions code/csv_to_geojson.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const data = [];
fs.createReadStream('data/permits_lat_long.csv')
.pipe(csv())
.on('data', (row) => {
// Assuming your CSV has 'latitude' and 'longitude' columns
data.push({
lat: parseFloat(row.lat),
lng: parseFloat(row.lng),
properties: row
});
// Convert latitude and longitude to numbers
row.lat = parseFloat(row.lat);
row.lng = parseFloat(row.lng);

// Add the row directly to the data array
data.push(row);
})
.on('end', () => {
const geoJson = GeoJSON.parse(data, {Point: ['lat', 'lng']});
Expand Down
2 changes: 1 addition & 1 deletion code/heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function jsonCallback(err, data) {
}

data.features = data.features.map((d) => {
d.properties.year = Number(d.properties.properties.year);
d.properties.year = Number(d.properties.year);
return d;
});

Expand Down
Loading

0 comments on commit 3ab8428

Please sign in to comment.