How to Reproject GeoJSON without crs property to WGS84 (to use React Leaflet) - geojson

(Please help I've been struggling with the same problem for more than three days...🤖)
I got GeoJSON file from National Statistical Office, which means it's official data- and the coordinates in this file look like this- :
[959394.1770449197,1948599.8772112513],
... ,
[1140386.5164449196,1684523.5489112514],
It's a GeoJSON object without a member named "crs", and as you can see, it's not using the WGS84 datum. Seems like it's coordinates to draw polygons, which are the shape of each district. I assume that there is no problem with data structure.
I tried to create map using this file with React Leaflet, but failed continuously. To find out if it's the problem of GeoJSON that I'm using, I used other GeoJSON files and it worked fine(meaning that interactive map was created on web) - By comparing the GeoJSON files, I found out that coordinates should be in WGS84 if I want to work with leaflet. So I tried to transform GeoJSON to WGS84 using reproject. In my react app project, I installed reproject, epsg and put the code below:
import * as mapData from '../data/sigunguWithPopGeo.json'
import { toWgs84 } from 'reproject'
import 'epsg'
let epsg = require('epsg');
toWgs84(mapData, undefined, epsg);
And the error was returned:
Error: Unable to detect CRS, GeoJSON has no "crs" property.
Thanks for reading this long intro - Finally here is my question.
Is there any way to reproject GeoJSON without "crs" property to WGS84? I also tried making the coordinates WGS84 with mapshaper.org. Again, I got the error caused by undefined coordinate system of GeoJSON file:
Unable to project -- source coordinate system is unknown
Should I consider adding crs property to GeoJSON? It's my very first time to create the interactive map using GeoJSON with React-leaflet, so any kind of advice from people who experienced similar projects would really help me!

Luckily, solved the problem by myself..!
Instead of keep looking for the methods to convert GeoJSON with undefined coordinate system to WGS84, I visited National Statistical Office's website to figure out the code of coordinate system that was used in src data - which was EPSG 5179. Then I converted GeoJSON file from EPSG 5179 to EPSG 4326(WGS84) on MyGeoData Converter. Before downloading the converted data, I checked on the map to see if the coordinates of data was successfully converted to proper lat, lng values. Hope this solution helps who are struggling with similar problems..👩‍🔧

Related

Rails/Slim auto-encoding Postgres geometric types

I have Google Maps polygons stored as polygons in Postgres and I read them straight from DB to output to a react Component for editing using the Google Maps API.
In my local dev environment this works fine and by inspecting the data being fed to the React component everything looks normal:
this.state = {
map: "POLYGON ((10.69332405332034 59.88086121809927, 10.77572151425784 59.84569766552776, 10.81554695371096 59.84121336506844, 10.8450727105469 59.84518027707294, 10.86910530332034 59.85397478713949, 10.91442390683596 59.88499566305687, 11.020510637793 59.9383527020427, 10.99115654233401 59.96809210273585, 10.91811462644046 59.99462872670429, 10.80250068906253 60.0067306049673, 10.58723732236331 59.97273110496651, 10.43772026303714 59.86724837030302, 10.44239803555911 59.85643166134471, 10.44501587155..."
}
But in production it seems some kind of compression/encoding is taking effect, rendering the data unusable to Google Maps:
this.state = {
map: "01030000000100000011000000004DF44CCD71164029B0493D19844D40004DF44C45AE1640E4A03B36D6814D40004DF44C75D81640139E06594D7F4D40004DF44C7532174001AC3D1CC47C4D40004DF44CAD0917404808CC83B0774D40004DF44CB5101740926DE6EDB2714D40004DF44C45081740393029BE276E4D40004DF44C8513174013D62165106C4D40004DF44C2DF31640637589D49B6A4D40004DF44CBD901640E794678CCA6B4D40004DF44C5535164080F6C4D4E16B4D40004DF44CCD17164099584C2D84724D40004DF44C553516400505C70B53784D40004DF44C1D31164037A2643EC17F4D40004DF44CC53D1640F4139BEDEA"
}
Background/environment
We recently had to take a server out of service and in its place we added two new ones to the load balancer. They were set up through Cloud 66 using the same config so they should be exaclty the same, but I guess you never know.
We use slim syntax for templates.
I should clarify: Nothing is being done explicitly by our application code to the map field on its way from Postgres to the React component. We get the database record like so: #coverage_map = CoverageMap.find(params[:id]) and then output it in the template like so: coverageMap: #coverage_map. The outputted data on display here is copied from the HTML template being rendered by Slim.
What could be happening here? Any tips on what to look for?
In your dev environment you're retrieving the geometry from the database as WKT (Well Known Text), which is not PostgreSQL's standard output. In production you're getting a WKB (Well Known Binary) representation of the geometry, which is what you normally see when firing a simple select. What you need is to use ST_AsText to get your WKT, e.g.
WITH mytable (geom) AS (
VALUES ('POINT(1 1)'::geometry)
)
SELECT geom,ST_AsText(geom) FROM mytable;
geom | st_astext
--------------------------------------------+------------
0101000000000000000000F03F000000000000F03F | POINT(1 1)
(1 Zeile)

Why doesn't camera_calibration.cpp tutorial code read from my camera correctly?

I am getting the following error when trying to run camera_calibration.cpp in the calib3d module of OpenCV's tutorial code samples, in streaming mode: Input does not exist: Invalid input detected. Application stopping. The input line in the xml input file looks like this: <Input>0</Input>, which should get the "0th" camera on my system.
I fixed this by enclosing the camera index in double quotes: <Input>0</Input> became <Input>"0"</Input>. (Simplistic parser... oh well, hope this helps some people.)

Google Earth Exported KMZ file not including URL attribute

I am working on a project to import google earth projects into an iOS application. When I export the Google earth project as a KML (or KMZ) the attributes of a polygon are not exported. As an example :
<Placemark>
<name>Boko Haram Territory - Current</name>
<styleUrl>#transGreenPoly</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
12.70213131043391,11.21355437778219,0 12.76213125508861,11.11351379017489,0 12.80421246808032,10.88806232016611,0 12.81140564976727,10.88474047056056,0 12.82588348845796,10.87462437857204,0 12.97939393108183,10.83966554281775,0 13.01510820482933,10.83000208944705,0 13.07942019606773,10.81053246258202,0 13.14001872784027,10.79444004548873,0 13.17185030048722,10.79508081378772,0 13.18953386465979,10.79543528924301,0 13.20368048739284,10.79571825387904,0 13.2743290941496,10.80058614475469,0 13.30607760464441,10.80467645272363,0 13.33421396206393,10.8121582665838,0 13.35520437351619,10.82296520370417,0 13.37982059654026,10.83038365174029,0 13.40082694596582,10.8411976344037,0 13.41829814104605,10.85194186295296,0 13.43237918897503,10.85568440985296,0 13.50979264821408,10.87798951527388,0 13.51679936970521,10.88159220711055,0 13.53768612847479,10.89933537465694,0 13.55497533303261,10.92048068470509,0 13.56880021101213,10.93809651898877,0 13.57915675601498,10.95217987296234,0 13.66923758481358,11.06510360559719,0 13.6691768923637,11.06858393737642,0 13.65988323190011,11.19395197671864,0 13.65250883139019,11.40721510169971,0 13.65213241070391,11.42824958002745,0 13.64837915330032,11.43870451829143,0 13.64112270150342,11.44558811843954,0 13.33559955678247,11.5522146556532,0 12.97984978381745,11.48909495336167,0 12.82247610438195,11.36661781158571,0 12.70213131043391,11.21355437778219,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
That is the info for a polygon- but the attributes that are suppose to be here #transGreenPoly are not contained in the file and thus my KML parser does not have enough info to draw the poly in iOS. If I add manual the style like this:
<Style id="transGreenPoly">
<LineStyle>
<width>1.5</width>
</LineStyle>
<PolyStyle>
<color>7d00ff00</color>
</PolyStyle>
</Style>
It will work, but since we are dealing with dozens of poly that is not a solution. Is there a way to get the style URL from Google Earth

Objective C and SVG

I am receiving a SVG back from our server that I need to display. What the server is returning is:
preview = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"256\" height=\"256\" preserveAspectRatio=\"xMedYMed meet\" viewBox=\"-10756457.3242036 -5943062.39021874 1277.60796701722 1244.16676712781\">\n <path d=\"M -10756407.324203580617905 -5942993.280961670912802 L -10756388.214946510270238 -5941880.166737286373973 -10755229.716236563399434 -5941868.223451617173851 -10755244.048179365694523 -5942728.140019812621176 -10755394.533578801900148 -5942730.528676947578788 -10755396.922235935926437 -5943012.390218744985759 -10755578.460178112611175 -5943005.224247347563505 -10755671.617806335911155 -5942995.669618809595704 -10755764.775434559211135 -5943005.224247347563505 -10755845.98977711237967 -5942990.892304535955191 -10755958.256662406027317 -5943000.446933076716959 -10756166.069833055138588 -5943002.835590209811926 -10756216.231632867828012 -5942998.058275939896703 -10756261.616118412464857 -5942990.892304535955191 -10756347.607775231823325 -5943002.835590209811926 Z\" stroke-width=\"1\" fill=\"black\" stroke=\"black\">\n </path>\n</svg>";
I am looking at the library the SVGKit. I'm not exactly sure what I can do with this information. Can SVGKit load this type of data or does it need to be a local SVG file?
We want to use this SVG cause its a lot smaller then a .png and the server is returning lots of them.
Any ideas on what I can do?
According to the documentation you can load an SVG file from data which is what you have.

Implementing bag of word algorithm from opencv sample codes

I am trying to implement bagofwords_classification.cpp from opencv version 2.4.5 sample codes.cpp . What are the changes that we are required to make in this .cpp file for proper working of code. I am new to opencv and still trying sample codes.
How and where to add the Feature detector,descriptor extractor, descriptor matcher ?? in that .cpp code
Whenever i debug any code it never display results but just output the info about what that .cpp file is gonna do. In (EXAMPLE) matching_to_many_images.cpp even the images are saved in the file but still no results are shown.
To show an image, you can use cvShowImage("Title",image) or imshow(). This depends on wheter to image is an IplImage or Mat.
The code example is not 'false', the program uses commandline arguments, thus to start it you need to add certain commands.
From the code
[feature detector]
Feature detector name (e.g. SURF, FAST...) - see createFeatureDetector() function.
[descriptor extractor]
Descriptor extractor name (e.g. SURF, SIFT) - see createDescriptorExtractor() function.
[descriptor matcher]
Descriptor matcher name (e.g. BruteForce) - see createDescriptorMatcher() function.
then from those arguments it calls
Ptr<FeatureDetector> featureDetector = createFeatureDetector( ddmParams.detectorType );
Ptr<DescriptorExtractor> descExtractor = createDescriptorExtractor( ddmParams.descriptorType );

Resources