Got GeoJSON Error? - Tip on Adding GeoJSON via URL in QGIS

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:

  1. Click the option Protocol: HTTP(S), cloud, etc.

  2. Select encoding type: UTF-8 or System (mine defaulted to UTF-8)

  3. Type: You can use either HTTP/HTTPS/FTP, Geojson, or Geojson - Newline delimited

  4. Type in URL and click Add

Fig0001.jpg

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.

Fig0002.png

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

Fig004A.png

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:

  1. Go System

  2. Expand Environment: check the box to Use custom vairables

  3. 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.

Fig0005.png

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.

Fig0010.png

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.

Label Rotation in QGIS and ArcGIS

Happy New Year! It’s been a long time since my last posting (it’s been a super busy 2019 for me) but I’m glad to be back with a new short tip. This super short post is in response to one of my readers who had a question regarding rotating angles in QGIS versus ArcGIS (Desktop & Pro). I didn’t find much in the official QGIS documentation about how labels or features are rotate, specifically on rotation types (e.g. Geographic or Arithmetic) and the direction (i.e clockwise, counter clockwise) in which the rotation occurs. I did see something on Github on unifying label rotation with other rotation settings - this says label rotation is specified in degrees clockwise, which I assumed corresponds to the Geographic rotation (clockwise direction from North) type in ArcGIS. However, when I did a test based on this assumption it did not produce the result I was expecting, so I did some trial and errors to figure it out. This is what I found out.

In ArcGIS you can specify the rotation types: Geographic or Arithmetic as seen in the diagrams below. Geographic rotates labels from north (North = 0) in a clockwise direction, while Arithmetic rotates labels from east (East = 0) in a counterclockwise direction.

Rotation Types

For my test, I have a shapefile of 5 points with rotation angles in three separate fields corresponding to geographic and arithmetic (both ArcGIS options) or QGIS that I want to my labels to be rotated by. I want my labels to look the same across the three options. It was easy to figure out the angles to use for the geographic and arithmetic options to have the labels to look the same, but it was trickier to figure out the angles in QGIS since the only thing I knew was the direction was clockwise.

Fig0003.jpg

All the features are labeled based on its feature name and the corresponding rotation angle value. This is result in ArcGIS using Geographic rotation type using the angles in the AGGeog field in the above table.

Fig0001.jpg

This is the result of ArcGIS Arithmetic rotation type using angles in the AGArith field.

ArcGIS Arithmetic rotation type

This is the result in QGIS .

Rotation angles labels QGIS

So, what my testing tells me is that in QGIS, label rotation is arithmetic base but going in clockwise direction - labels rotate starting from East (E=0) going clockwise. Here is a diagram I drew to help visualize the differences in ArcGIS and QGIS.

Rotation angles QGIS and ArcGIS

That’s it for this post. Until next time.