Combining additional data with Shapefile using GeoJSON and Gdal - csv

I used Mike Bostock's great tutorial to make a simple map using downloaded shapefiles and processing them with GDAL into GeoJSON files.
http://bost.ocks.org/mike/map/
I'm trying to build on this learning by taking a county-level shapefile map and marrying it with additional demographic data (CSV) so that I can load a single GeoJSON file and not have to use Javascript to merge the data at runtime. The goal is to have a county-level heatmap.
The CSV file has an ID column that looks like this: 01348. While the Shapefile has two ID columns that are 01 and 348.
Is it possible to use GeoJSON to store this kind of data? If so, what kind of terminal commands must I use to combine the two?

Little trick:
When converting from Shape file to GeoJSON, keep "id-a":"01";"id-b":"348" as neighbors in this order.
use a simple regex to delete all ";"id-b":" and thus obtain "id-a":"01348".
go ahead to inject your CSV property given the common ID, see: How to add properties to topojson file?
That's should work.

Related

extracting data in csv or excel form from an interactive map

I'm not a programmer but i was wondering if it would be possible to extract a list of zipcodes and median income in either csv or excel form from this interactive map.
http://www.wnyc.org/story/174508-blog-census-locates-citys-wealthiest-and-poorest-neighborhoods/
Data used from the map is coming from this website:
http://factfinder.census.gov/faces/nav/jsf/pages/index.xhtml
You can find also here some data related:
http://www.census.gov/quickfacts/map/RHI225214/36
About your map, i recommend you to find another way to extract those data, like a database or a tool available on a website, or use links provided.

Is it possible to export geometry data from a shapefile to CSV from QGIS?

I'm trying to get geometry data from a large quantity of shapefiles into a database (Google Datastore). The thing is, I don't need to work with maps, I just need the coordinates, so I would like just the numerical coordinates. Ideally I'd like to use CSV, but any plain text would be workable. I have a Mac and have been able to get QGIS installed (I also tried udig but the interface was baffling). While it is easy to load a shp file into QGIS as a vector layer, I'm lost as to how to export the geometry, or even if it is possible.
Does anyone know how to extract plain text geometry from a shp file? Ideally with QGIS, but any method would be appreciated.
The "You can simply right-click the layer entry in QGIS and select "Save as"" approach was right
But the "GEOMETRY=AS_WKT" in the OGR layer option was missing.
I may also be a good idea to convert the coordinate system to WGS 84, as CSV are usually expected not to be projected (and shapefile sometimes are)
You can simply right-click the layer entry in QGIS and select "Save as".
In the dialog, there's an option to save as "CSV".
There are plenty of options to refine the format of the generated CSV file, as well as there are many other file formats to choose from.
Update:
See here for a solution: https://gis.stackexchange.com/a/8846
Outdated Response:
It is possible, in a sort of roundabout way...
Open the attribute table for the layer you want to save.
Select all rows.
Copy the rows
Paste into a spreadsheet
Save the spreadsheet as a csv.
Unfortunately there is no way to do this directly in QGIS.
See here for more details:
https://gis.stackexchange.com/questions/8844/get-list-of-coordinates-for-points-in-a-layer/8911#8911

export plots with netlogo

I am trying to export all the plots of my NetLogo model after simulation runs in a csv format with the primitive export-all-plots.
I haven't found yet the way to open this csv file with an external reader in order to get more clear plots. I tried with gnuplot but it looks like it's not able to open the csv format created with NetLogo:
"export-plots data (NetLogo 5.0.5)"
^
"C:\results\interface.csv", line 1: invalid command
How can I open csv plots with an external reader?
There are two complicating factors about NetLogo's plot export format. First, there's a three line header at the beginning (plus an empty line after) that just gives information about the model and when the data was generated. Next, there's data about the model settings, the plot state (pen colors and such). Finally, there's the data itself, which itself is somewhat complicated by the fact that you can have multiple pens per plot. So I'm not surprised gnuplot couldn't read it as is.
The table's are quite easy to use in GUI spreadsheet application, like Excel, LibreOffice's Calc, or Gnumeric. You can just select the data you want and generate the plots.
To do this at the command line, I'm afraid you might have to write a script to read it in. This should be pretty easy in something like Python or R. Just skip the metadata lines, and use a CSV parser to read in the rest.
You might also try using BehaviorSpace to generate the data, but make sure to use the table output. It let's you generate the data from many runs at once, and the format is a little more consistent. There are still 6 lines of metadata at the top, but you can just delete that. I believe this is more the standard practice in NetLogo.

Cities displayed in topojson visualization, but not in file itself?

I am looking at this json file: https://gist.github.com/d3noob/5193723#file-world-110m2-json. In the visualization done by github, the file seems to encode data about cities and towns. However when I look at the json file itself, this data does not seem to be in there (the only objects are land and countries, no cities), and I am not sure how to get this data into my d3 visualization. Am I misunderstanding something about this file/how topojson is encoded?
The github visualisation displays the data in the JSON (orange) overlaid on Google Maps. What's in the JSON are just the orange outlines. If you want cities etc in your map, you'll have to create a separate TopoJSON file, see this tutorial for more information.

Dynamic graph generation from .csv file using JFreeChart

I'm using JFreeChart to generate line graphs from a simple array of integers.
However, I'd like to use a csv file for the input of the graph. Are there any applications which do it automatically? Also, my csv file will new entries appended every 3 seconds. How can I generate dynamic graphs? I will have to use these graphs in a swing application. Thanks!
I've had good luck with org.h2.tools.Csv, part of H2 Database. You might also look at org.jfree.data.io.CSV, "A utility class for reading CategoryDataset data from a CSV file."