Skip to content

Add Sample Datasets

Xun Li edited this page Mar 5, 2024 · 8 revisions

Author: Xun Li

  1. In GdaConst.cpp file, add or remove the dataset in the following three vectors:
const std::vector<wxString> GdaConst::sample_names;
const std::vector<wxString> GdaConst::sample_layer_names;
const std::vector<wxString> GdaConst::sample_datasources;
const std::vector<wxString> GdaConst::sample_meta_urls;
  1. Edit samples.sqlite under BuildTools/CommonDistFiles/web_plugins directory

Using ogr2ogr to append new shapefile to sample.sqlite, e.g.

ogr2ogr -update -append -f SQLite samples.sqlite -nln "Chicago Community Areas" -oo ADJUST_TYPE=YES -t_srs "EPSG:4326" Chicago\ CCA\ Profiles/Chicago_2020.shp
ogr2ogr -update -append -f SQLite samples.sqlite -nln "Ceara Zika" -oo ADJUST_TYPE=YES -t_srs "EPSG:4326" Ceara/ceara.shp
ogr2ogr -update -append -f SQLite samples.sqlite -nln "Chicago Carjackings" -oo ADJUST_TYPE=YES -t_srs "EPSG:4326" Chicago\ Carjackings/Chicago_Carjackings.shp
ogr2ogr -update -append -f SQLite samples.sqlite -nln "Chicago SDOH" -oo ADJUST_TYPE=YES -t_srs "EPSG:4326" Chicago\ SDOH/Chi-SDOH.shp
ogr2ogr -update -append -f SQLite samples.sqlite -nln "Oaxaca Development" -oo ADJUST_TYPE=YES -t_srs "EPSG:4326" Oaxaca/oaxaca.shp
ogr2ogr -update -append -f SQLite samples.sqlite -nln "Italy Community Banks" -oo ADJUST_TYPE=YES -t_srs "EPSG:4326" Italy\ Banks/italy_banks.shp
ogr2ogr -update -append -f SQLite samples.sqlite -nln "Spirals" -oo ADJUST_TYPE=YES spirals/spirals.shp

ogr2ogr -update -append -f SQLite samples.sqlite -nln "Chicago Community Areas" -oo ADJUST_TYPE=YES Chicago\ CCA\ Profiles/Chicago_2020.shp
ogr2ogr -update -append -f SQLite samples.sqlite -nln "Ceara Zika" -oo ADJUST_TYPE=YES Ceara/ceara.shp
ogr2ogr -update -append -f SQLite samples.sqlite -nln "Chicago Carjackings" -oo ADJUST_TYPE=YES Chicago\ Carjackings/Chicago_Carjackings.shp
ogr2ogr -update -append -f SQLite samples.sqlite -nln "Chicago SDOH" -oo ADJUST_TYPE=YES Chicago\ SDOH/Chi-SDOH.shp
ogr2ogr -update -append -f SQLite samples.sqlite -nln "Oaxaca Development" -oo ADJUST_TYPE=YES Oaxaca/oaxaca.shp
ogr2ogr -update -append -f SQLite samples.sqlite -nln "Italy Community Banks" -oo ADJUST_TYPE=YES Italy\ Banks/italy_banks.shp
ogr2ogr -update -append -f SQLite samples.sqlite -nln "Spirals" -oo ADJUST_TYPE=YES spirals/spirals.shp

# overwrite a table
ogr2ogr -update -overwrite -f SQLite samples.sqlite -nln "Chicago Community Areas" -oo ADJUST_TYPE=YES chicaog_2020_sdoh/Chicago_2020_sdoh.shp

Note: the dbf file format has a number of limitations (see here):

  • Integer fields without an explicit width are treated as width 9, and extended to 10 or 11 if needed.
  • Integer64 fields without an explicit width are treated as width 18, and extended to 19 or 20 if needed.

By default, the GDAL library will read the dbf and select the larger data type. For example, a numeric column with width 19/20 may hold as Real. So, it is possible an Integer64 column with width 20 could be read as Real.

There is one option ADJUST_TYPE=YES/NO that can be used to adjust Real->Integer/Integer64 or Integer64->Integer field types when possible. (see Open options)

Therefore, we need to add -oo ADJUST_TYPE=YES in the above ogr2ogr command.

  1. Add thumbnail image for new sample dataset under BuildTools/CommonDistFiles/web_plugins directory

Using template.png with size 220 x 161 Placing watermark-20.png on left corner

  1. Add web page for each sample dataset for GeoDaCenter.github.io/data-and-lab