How can I convert Statistics Canada from SHP/GML/MAP to JSON? - leaflet

I'm trying to do a choropleth on leaflet with data from Statistics Canada. For some reason, I just can't convert the data from this page: https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2016-eng.cfm
I've tried many ways and failed. The closest I went to reach my goal was with mapshaper, but for some reason I didn't get any latitude/longitude data (46.xxxxx, -75.xxxxx) but positive numbers like 80.xxxxx, 45.xxxx.
How should I proceeed?
Thanks
P.S. I tried GDAL but couldn't find any .exe file to launch the software after download and didn't understand how it works.
P.S.1. Here is some data I got... Don't understand how to use the data. It doesn't look like latitude/longitude at all...
{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[4430789.257144999,2586893.2714300007],[4431394.088569999,2586921.9685700014],[4431518.514284998,2586927.8885699995],[4431559.800000001,2586929.8542850018],[4431835.059999999,2586942.9514300004],[4431902.997145001,2586946.185715001],[4431956.248569999,2586948.719999999],[4432181.440000001,2586960.148570001],[4432128.4428550005,2586865.5199999996],[4431235.722855002,2585271.4542849995],[4431224.805714998,2585248.0714300014],[4431139.31143,2585064.97143],[4431126.077144999,2585036.6257149987],[4431113.082855001,2585041.462855],[4431099.960000001,2585046.3485700004],[4431043.482855,2585058.5571449995],[4431041.705715001,2585058.182854999],[4430982.808570001,2585045.725715],[4430837.440000001,2584980.262855001],[4430824.97143,2584974.6457149982],[4430780.539999999,2584963.0714300014],[4430736.842854999,2584951.685715001],[4430680.731430002,2584947.1799999997],[4430511.717145,2584953.4657149985],[4430414.174284998,2584931.6999999993],[4430378.485715002,2584923.737144999],[4430294.1000000015,2584920.657145001],[4430239.185715001,2584930.5085700005],[4430155.577144999,2584975.594285],[4430054.191429999,2585030.3599999994],[4429933.685715001,2585066.622855],[4429921.86857,2585066.514284998],[4429666.431430001,2585064.182854999],[4429575.760000002,2585095.2714300007],[4429442.445714999,2585221.5857149996],[4429343.168570001,2585261.280000001],[4429301.68,2585277.86857],[4429261.420000002,2585283.445714999],[4429121.1114300005,2585276.3228549995],[4428957.585715,2585294.3542850018],[4428828.705715001,2585321.13143],[4428751.162854999,2585352.4657149985],[4428750.277144998,2585352.8228549995],[4428718.054285001,2585365.845715001],[4428637.305714998,2585363.6771450005],[4428622.734285001,2585363.2885700017],[4428553.365715001,2585313.81143],[4428546.794284999,2585309.1257149987],[4428514.47143,2585219.460000001],[4428492.162854999,2585182.8885699995],[4428453.15143,2585157.037145],[4428411.182854999,2585162.351429999],[4428359.0085700005,2585183.6428549998],[4428334.168570001,2585201.4371449985],[4428262.808570001,2585252.5599999987],[4428225.185715001,2585268.4771450013],[4428213.52857,2585268.960000001],[4428170.577144999,2585270.7342850007],[4428117.485715002,2585261.405715],[4428081.605714999,2585241.280000001],[4428041.47143,2585200.622855],[4428023.911430001,2585182.8371450007],[4428022.371429998,2585181.274285],[4427887.0085700005,2584943.9285699986],[4427726.805714998,2584804.6657150015],[4427605.1000000015,2584734.63143],[4427576.18857,2584717.9942849986],[4427446.197145,2584627.502854999],[4427298.408569999,2584555.2457149997],[4427225.285714999,2584533.7971450016],[4427129.462855,2584525.5885699987],[4427124.137145001,2584527.905715],[4427100.1657150015,2584538.342854999],[4426983.777144998,2584638.9428550005],[4426972.920000002,2584647.6514299996],[4426961.9542849995,2584656.445714999],[4426754.628570002,2584800.9142850004],[4426731.865715001,2584816.774285],[4426639.82,2584910.445714999],[4426580.5,2584934.917144999],[4426549.054285001,2584928.948569998],[4426535.897144999,2584922.7542850003],[4426509.608569998,2584831.748569999],[4426510.108569998,2584790.6742849983],[4426511.962855,2584638.8228549995],[4426506.719999999,2584571.1400000006],[4426493.300000001,2584526.3914300017],[4426454.648570001,2584469.714285001],[4426407.805714998,2584442.8485700004],[4426403.394285001,2584440.3200000003],[4426378.148570001,2584444.582855001],[4426294.822854999,2584493.9657149985],[4426228.277144998,2584584.120000001],[4426193.805714998,2584596.0571449995],[4426158.982855,2584608.1142849997],[4426145.828570001,2584605.1657150015],[4426132.539999999,2584602.18857],[4426102.337145001,2584551.8542850018],[4426092.905715,2584481.3999999985],[4426135.642855,2584364.1371450014],[4426151.374285001,2584320.97143],[4426158.448569998,2584254.1685700007],[4426134.18,2584199.6142849997],[4426079.505715001,2584135.405715],[4425995.628570002,2584106.511429999],[4425910.905715,2584077.3228549995],[4425781.802855,2584060.0599999987],[4425770.45143,2584058.539999999],[4425751.785714999,2584046.8200000003],[4425703.817145001,2584016.6999999993],[4425668.725715,2583994.6657150015],[4425657.177145001,2583982.7828550003],[4425618.154284999,2583942.6400000006],[4425567.071430001,2583890.0885699987],[4425540.722855002,2583868.4028550014],[4425528.0571449995,2583857.9800000004],[4425514.108569998,2583846.5],[4425483.277144998,2583828.448569998],[4425482.414285,2583827.9428550005],[4425424.588569999,2583794.0885699987],[4424859.254285,2584450.20857],[4424750.0085700005,2584630.317145001],[4424629.120000001,2584932.4828549996],[4424596.391430002,2585249.5571449995],[4424546.914285,2585230.8714299984],[4424562.125714999,2585263.6999999993],[4424567.997145001,2585276.36857],[4424602.577144999,2585350.997145001],[4424659.34857,2585473.1028550006],[4424707.691429999,2585575.714285001],[4424767.5457150005,2585702.7657149993],[4424815.702854998,2585787.4542849995],[4424877.174284998,2585866.5057150014],[4424933.671429999,2585925.0199999996],[4424993.325715002,2585975.922855001],[4425020.497145001,2585996.16],[4425072.194285002,2586034.6657150015],[4425163.960000001,2586103.014284998],[4425205.785714999,2586134.1685700007],[4425318.294284999,2586217.9685700014],[4425538.737144999,2586382.1628549993],[4425571.117144998,2586403.094285],[4425596.094285,2586419.2428550012],[4425716.405715,2586482.7457149997],[4425885.928569999,2586553.1257149987],[4426088.460000001,2586635.537145],[4426304.728569999,2586724.511429999],[4426387.877145,2586758.3057149984],[4426473.531429999,2586793.117144998],[4426486.31143,2586798.31143],[4426489.04857,2586799.422855001],[4426494.68,2586801.7114299983],[4426641.042854998,2586861.197145],[4426937.559999999,2586981.654284999],[4427057.84,2587027.634284999],[4427189.305714998,2587061.6371450014],[4427292.337145001,2587078.780000001],[4427681.614285,2587092.4257149994],[4427687.828570001,2587092.1771450005],[4428045.448569998,2587077.9514300004],[4428085.280000001,2587076.36857],[4428347.585715,2587065.9371449985],[4428391.420000002,2587064.1942850016],[4428547.757144999,2587047.905715],[4428973.428569999,2587003.5599999987],[4429331.29143,2586965.9914299995],[4429416.15143,2586957.082855001],[4429560.537145,2586941.9257149994],[4429640.15143,2586933.5714300014],[4430146.242855001,2586880.4514300004],[4430256.982855,2586872.697145],[4430474.82,2586878.3542850018],[4430616.199999999,2586885.0628550015],[4430789.257144999,2586893.2714300007]]]},"properties":{"ADIDU":"59550131","PRIDU":"59","PRNOM":"British Columbia / Colombie-Britannique","DRIDU":"5955","DRNOM":"Peace River","DRGENRE":"RD","SRUIDU":"5955023","SRUNOM":"Peace River E","SDRIDU":"5955023","SDRNOM":"Peace River E","SDRGENRE":"RDA","RÉIDU":"5980","RÉNOM":"Northeast / Nord-est","CSSCODE":"997","CSSGENRE":"5","RMRIDU":"","RMRPIDU":"","RMRNOM":"","RMRGENRE":"","SRIDU":"","SRNOM":"","ADAIDU":"59550004"}},
{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[4434380.18,2584958.6914299987],[4434198.559999999,2584518.0599999987],[4433504.168570001,2584830.537145],[4433665.617144998,2585139.157145001],[4433345.037145,2585299.3314299993],[4433289.780000001,2585389.7285699993],[4433205.268569998,2585453.1657150015],[4433066.468570001,2585557.3485700004],[4433028.65143,2585471.117144998],[4432985.671429999,2585373.1085699983],[4432881.705715001,2585070.3200000003],[4432024.308570001,2585503.605714999],[4432018.0457150005,2585506.31143],[4432000.928569999,2585561.945714999],[4431943.66,2585581.3257150017],[4431909.371429998,2585581.785714999],[4431870.342854999,2585598.0342850015],[4431826.800000001,2585588.8857150003],[4431799.382855002,2585581.351429999],[4431794.302855,2585569.6457149982],[4431799.294284999,2585558.068569999],[4431854.408569999,2585536.6457149982],[4431856.308570001,2585521.2428550012],[4431845.734285001,2585505.7057150006],[4431816.20857,2585514.7171449997],[4431789.277144998,2585510.051430002],[4431773.9428550005,2585489.4428550005],[4431722.205715001,2585485.8314299993],[4431714.865715001,2585471.97143],[4431718.420000002,2585439.025715001],[4431710.102855001,2585425.6457149982],[4431642.34857,2585415.0057150014],[4431633.685715001,2585400.7657149993],[4431633.725715,2585399.774285],[4431635.077144999,2585367.8628549986],[4431627.082855001,2585361.1142849997],[4431599.262855001,2585367.002854999],[4431588.031429999,2585360.6685700007],[4431550.5,2585308.4657149985],[4431529.597144999,2585317.2971450016],[4431510.8885699995,2585338.417144999],[4431505.36857,2585382.2771449983],[4431482.920000002,2585415.8857150003],[4431457.108569998,2585454.5314299986],[4431448.842854999,2585455.582855001],[4431436.385715,2585434.3857150003],[4431428.95143,2585395.154284999],[4431434.088569999,2585356.877145],[4431425.422855001,2585342.634284999],[4431398.817145001,2585344.6000000015],[4431378.774285,2585388.497145001],[4431362.154284999,2585405.0885699987],[4431333.071430001,2585398.3857150003],[4431332.817145001,2585397.7542850003],[4431361.705715001,2584923.328570001],[4431369.391430002,2584797.091430001],[4431365.81143,2584802.817145001],[4431338.217145,2584837.685715001],[4431253.317145001,2584944.9657149985],[4431194.851429999,2584997.5428549983],[4431186.114285,2585005.3999999985],[4431171.8342849985,2585012.828570001],[4431126.077144999,2585036.6257149987],[4431139.31143,2585064.97143],[4431224.805714998,2585248.0714300014],[4431235.722855002,2585271.4542849995],[4432128.4428550005,2586865.5199999996],[4432181.440000001,2586960.148570001],[4432305.068569999,2586968.1799999997],[4432800.374285001,2587016.622855],[4432956.871429998,2587032.448569998],[4432985.4542849995,2587035.34],[4433004.914285,2587037.0885699987],[4433017.225715,2587040.6257149987],[4433058.0571449995,2587040.9685700014],[4433109.694285002,2587033.737144999],[4433157.394285001,2587019.9800000004],[4433180.562855002,2587009.02857],[4433184.52857,2587007.157145001],[4433187.605714999,2587005.7028549984],[4433226.788570002,2586985.9514300004],[4433261.628570002,2586959.5571449995],[4433314.011429999,2586913.9800000004],[4433319.117144998,2586905.2171449997],[4433378.357145,2586854.8228549995],[4433419.282855,2586819.814284999],[4433432.1657150015,2586808.7942849994],[4433689.391430002,2586588.7571449988],[4433708.591430001,2586568.6942850016],[4433752.885715,2586517.654284999],[4433788.237144999,2586462.2228550017],[4433892.879999999,2586279.551430002],[4433950.32,2586181.9942849986],[4433992.754285,2586112.237144999],[4434034.194285002,2586061.9542849995],[4434082.042854998,2586012.905715],[4434145.668570001,2585962.2228550017],[4434171.379999999,2585941.814284999],[4434191.837145001,2585925.577144999],[4434212.371429998,2585909.2771449983],[4434228.559999999,2585896.4285699986],[4434256.702854998,2585874.0885699987],[4434271.657145001,2585862.219999999],[4434281.760000002,2585854.1999999993],[4434315.322854999,2585818.2600000016],[4434345.485715002,2585770.280000001],[4434349.085715,2585761.3542850018],[4434366.265714999,2585718.7342850007],[4434372.645714998,2585685.9142850004],[4434375.314284999,2585650.345715001],[4434376.911430001,2585629.0971449986],[4434365.122855,2585563.317145001],[4434355.95143,2585513.6742849983],[4434313.857145,2585279.997145001],[4434312.037145,2585244.845715001],[4434314.731430002,2585187.2228550017],[4434315.625714999,2585168.0314299986],[4434326.828570001,2585093.908569999],[4434336.04857,2585064.671429999],[4434349.808570001,2585021.037145],[4434368.15143,2584981.274285],[4434374.120000001,2584968.3342849985],[4434380.18,2584958.6914299987]]]},"properties":{"ADIDU":"59550132","PRIDU":"59","PRNOM":"British Columbia / Colombie-Britannique","DRIDU":"5955","DRNOM":"Peace River","DRGENRE":"RD","SRUIDU":"5955023","SRUNOM":"Peace River E","SDRIDU":"5955010","SDRNOM":"Chetwynd","SDRGENRE":"DM","RÉIDU":"5980","RÉNOM":"Northeast / Nord-est","CSSCODE":"998","CSSGENRE":"6","RMRIDU":"","RMRPIDU":"","RMRNOM":"","RMRGENRE":"","SRIDU":"","SRNOM":"","ADAIDU":"59550004"}},

Related

How can I get a list of bridges with their location (latitude and longitude) from an OSM file?

maybe this query may be a bit trivial or perhaps laborious, but for a project I need to obtain the bridges that exist in an osm file along with its location (latitude and longitude).
Reading the openstreetmap wiki, I see that there is a procedure using osmosis but I do not know if I will actually get the information as follows:
Name of the bridge | latitude | longitude
bin / osmosis.bat --rx brandenburg.osm.bz2 --bp file = "city.poly" --tf accept-ways highway=motorway_link,motorway --way-key-value keyValueList="bridge.yes" --used-node --write-xml brdg_autob.osm
Thanks in advance
Pablo
The output will be OSM XML and not plaintext.
Also, most bridges in OSM are mapped as ways. A way consists of multiple lat/lons represented as nodes. If you need a single lat,lon pair then you have to calculate the bridge center yourself.
Additionally, not all bridges are tagged as bridge=yes. See bridge in the OSM wiki for a list of commonly used tags, such as bridge=viaduct, bridge=aqueduct, bridge=boardwalk and so on.
You won't exactly get the format you described. However with some little work you can transform OSM XML into your format.

ADHoc Information Retrieval

I want to extract the total bill from image receipts. I could extract the entire data present in the image but now I am struck with the problem of extracting only the information that I need.
This is the image that I have.
I am pasting the extracted information from the image
m cm lnnk 3mm: :33; no 1 z m
x Visut all! ms“; (or nulnunn mfn an an: nan.
Sub Iota] 19.56
TOTAL 19.56
VISA 1956
Fun 19.56
D!!! You Know 0
For ureat-tastlru dessens under 200
cahries, try our Triple Berry Frozen
Yogurt Sunda: a dish of Frozen Yogurt.
or a Vanma rozen Vugurt Done.
From this data I just want to extract the total bill. To get this I found out that I could use Ad Hoc Normalization (Adhoc retrieval). Can someone provide any insights on Adhoc retrieval. If there are any other option to extract the data from the image please let me do so. I am using tesseract to extract this information. Sometimes it is no giving the proper output. I could use some help in improvising the output given by the tesseract.
Why do you need ad hoc retrieval in this case? Since you are getting the OCR result from the receipt, you can simply perform a regular text search for the item appearing next to "TOTAL".
There are algorithms for image text search, but this seems like overkill for such a straightforward application unless there is a good reason to do so.

Twitter advanced search by date AND location for research purposes

I'm trying to research a topic and I need to get all tweets within 2013 and 2015 and a specific location for two keywords.
I tried to get the results via Advanced Search but I allways get no results.
I tried:
cannabis near:"España" within:15mi since:2013-10-07 until:2015-01-01
cannabis near:"Spain" within:15mi since:2013-10-07 until:2015-01-01
Basically, I have a database of scraped press articles sorted by date from a bunch of sources, and I want to know how the agenda of this news sources have an impact on the social media conversation.
I could do it over Reddit if it was the case for the US, but there's no Spanish alternative (well, we have Meneame, but the user base is very left-leaning and I think it will be very narrow).
So I wanted to either scrape the search results or get them via API, but It's not working, and AFAIK I can't do anything similar with Facebook.
One way to achieve this is by using Twitter's geocode operator. In the example below i took Madrid as a center and covered a radius of 600km around it like this:
(canabis OR cannabis) geocode:40.4381311,-3.8196196,600km since:2013-10-07 until:2015-12-31
Try it...
The syntax is as follows:
([your_boolean_search_query]) geocode:[latitude],[longitude],[radius]km since:[] until:[]
one easy way to find latitudes and longitudes of locations is to use Google Maps. Simply navigate to a place using the search box and then copy the latitude and longitude element from the URL line in the browser. Here it is for Madrid. The latitude and longitude are right after the # sign, separated by a comma:
https://www.google.com/maps/place/Madrid,+Spain/#40.4381311,-3.8196196,54451m/data=!3m2!1e3!4b1!4m5!3m4!1s0xd422997800a3c81:0xc436dec1618c2269!8m2!3d40.4167754!4d-3.7037902?hl=en
Try it...

How can I search for elements within a polygon with Overpass?

I am new to Overpass API and GIS in general.
Is there an easy way to export all buildings in a specific region using coordinates to specify the polygon? I couldn't find a solution using the wiki and google so far.
I have large sets of coordinates which are determining some medium-voltage grids.
Or is there another tool I could use?
I want to use the polygon- coordinates of the exported buildings in matlab.
Thanks for your help!
Overpass API provides the (poly: ) filter to query objects inside a given polygon. See the documentation in the wiki for details.
Buildings in a given polygon can be queried as follows:
way[building](poly:"50.7 7.1 50.7 7.12 50.71 7.11");
(._;>;);
out meta;
Due to a recent memory limitation, you might have to either add a [maxsize: xxx] setting:
[maxsize:2073741824];
way[building](poly:"50.7 7.1 50.7 7.12 50.71 7.11");
(._;>;);
out;
or resort to the following workaround to force another evaluation sequence:
way(poly: "50.7 7.1 50.7 7.12 50.71 7.11");
way._[building];
(._;>;);
out meta;

postgis shape file import problems

Hi I'm trying to import a shape file from
http://www.nyc.gov/html/dcp/html/bytes/bytesarchive.shtml
into a postgis database. the above files creates MULTIPOLYGONS when i import using shp2pgsql.
then i'm trying to simply determine if lat/long points are contained in my multipolygons
however my select's are not working, and when i print out the poitns of my the_geom column it seems to be very broken.
select st_astext(geom) from (select (st_dumppoints(the_geom)).* from nybb where borocode =1) foo;
gives the result...
st_astext
------------------------------------------
POINT(1007193.83859999 257820.786899999)
POINT(1007209.40620001 257829.435100004)
POINT(1007244.8654 257833.326199993)
POINT(1007283.3496 257839.812399998)
POINT(1007299.3502 257851.488900006)
POINT(1007320.1081 257869.218500003)
POINT(1007356.64669999 257891.055800006)
POINT(1007385.6197 257901.432999998)
POINT(1007421.94509999 257894.084000006)
POINT(1007516.85959999 257890.406100005)
POINT(1007582.59110001 257884.7861)
POINT(1007639.02150001 257877.217199996)
POINT(1007701.29170001 257872.893099993)
...
for points in nyc, this is very off.. what am i doing wrong?
The points are not of. The spatial data that is referred to is NOT in lat/long. This is why numbers are different from what you expect. If you need it to be in long/lat it must be reprojected. See more here: http://postgis.refractions.net/news/20020108/
The projection of the data seems to be in the NAD_1983_StatePlane_New_York_Long_Island_FIPS_3104_Feet coordinate system (according to the metadata - see code.).
<spref>
<horizsys>
<planar>
<planci>
<plance Sync="TRUE">coordinate pair</plance>
<coordrep>
<absres Sync="TRUE">0.000000</absres>
<ordres Sync="TRUE">0.000000</ordres>
</coordrep>
<plandu Sync="TRUE">survey feet</plandu>
</planci>
<mapproj><mapprojn Sync="TRUE">Lambert Conformal Conic</mapprojn><lambertc><stdparll Sync="TRUE">40.666667</stdparll><stdparll Sync="TRUE">41.033333</stdparll><longcm Sync="TRUE">-74.000000</longcm><latprjo Sync="TRUE">40.166667</latprjo><feast Sync="TRUE">984250.000000</feast><fnorth Sync="TRUE">0.000000</fnorth></lambertc></mapproj></planar>
<geodetic>
<horizdn Sync="TRUE">North American Datum of 1983</horizdn>
<ellips Sync="TRUE">Geodetic Reference System 80</ellips>
<semiaxis Sync="TRUE">6378137.000000</semiaxis>
<denflat Sync="TRUE">298.257222</denflat>
</geodetic>
<cordsysn>
<geogcsn Sync="TRUE">GCS_North_American_1983</geogcsn>
<projcsn Sync="TRUE">NAD_1983_StatePlane_New_York_Long_Island_FIPS_3104_Feet</projcsn>
</cordsysn>
</horizsys>
</spref>
If you work much with spatial data I suggest that you read more about map projection.
I think this is not issue with PostGIS. I checked input esri Shape file nybb.shp with AvisMap Free Viewer and as you see points are weird itself:
However there is something interesting in nybb.shp.xml metadata file:
<spdom>
<bounding>
<westbc Sync="TRUE">-74.257465</westbc>
<eastbc Sync="TRUE">-73.699450</eastbc>
<northbc Sync="TRUE">40.915808</northbc>
<southbc Sync="TRUE">40.495805</southbc>
</bounding>
<lboundng>
<leftbc Sync="TRUE">913090.770096</leftbc>
<rightbc Sync="TRUE">1067317.219904</rightbc>
<bottombc Sync="TRUE">120053.526313</bottombc>
<topbc Sync="TRUE">272932.050103</topbc>
</lboundng>
</spdom>
I am not familiar with those toolkit (ESRI ArcCatalog), but most probably you need to rescale your points after import using that metadata.