This post an addendum to an older, previous post on Adding and Viewing GeoJSON in QGIS and ArcGIS. This comes from a tip I provided a blog reader who was having trouble adding geojson file via URL in QGIS from Fulcrum. If you are having trouble connecting to geojson data via URL, give this tip a try and see if it works.
QGIS 3.10 is the version I’m using. Below is the link to an example geojson file I’m testing in this post.
Example geojson URL: https://www.nanaimo.ca/crimereporting/api/incidents.geojson
Errors when trying to Add geojson
Brief summary on how to add Geojson:
Go to Layer Menu >> Layer >> Add Layer >> Add Vector Layer
In the Data Source Manager window:
Click the option Protocol: HTTP(S), cloud, etc.
Select encoding type: UTF-8 or System (mine defaulted to UTF-8)
Type: You can use either HTTP/HTTPS/FTP, Geojson, or Geojson - Newline delimited
Type in URL and click Add
It should add the geojson file to my map BUT instead I get this error: Invalid Data Source. Clicking Yes to try File source type fails also.
When looking in the error log messages (click the message button in the bottom right if you don’t see the log messages panel) - I see the errors that the geojson url is invalid data source and that there is a SSL certificate problem as seen in the images below
My understanding from doing some research is that this occurs in QGIS because of outdated openssl library. To work around this you could try use changing the link to just use http instead of https — sometimes this works but in my case it did not. Below are the work around options to try:
Change the environmental setting variables in QGIS
Go to Setting Menu >> Options
In the Options window:
Go System
Expand Environment: check the box to Use custom vairables
Then add the following Variables
Variable: GDAL_HTTP_USERAGENT
Variable Value: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36
Variable: GDAL_HTTP_UNSAFESSL
Variable Value: YES
Restart QGIS and them try to add the GeoJSON file link again.
If the above work around doesn’t work you may want to also add the variables to your OS system properties and see if that works.
So now if I reopen QGIS and add in the geojson URL it should work - this is what you should see if you use the example URL link given above.
That’s it for this post. I hope this helps for those having trouble adding geojson files via URL. If you have any questions, comments, or suggestions for future blog posts please let me know.
Thanks for reading. Until next time.