Select to view content in your preferred language

Converting geoJSON to .lyrx file to set symbology (heatmap) using arcpy

12-12-2023 08:16 PM
New Contributor

Hi everyone,

I am new to ArcGIS Pro and related softwares. I currently am using FME to extract data and convert it into a geoJSON file to visualise on ArcGIS Pro. This plots the points. When using arcGIS pro, I need to import it using the JSON to Features tool. Visually, I want the data as a heat map, therefore I can click my data and set the 'Symbology' of it to Heat Map (rather than Single Point). 

This is the goal. Although, I want it all automated and have just a .lyrx file for people to drag-drop it into ArcGIS Pro and it is already formatted as a Heat Map - I have tested this by generating a layer and opening it separately through drag-drop. I am currently using arcpy to achieve this. My python script currently converts my geoJSON file to a feature class using gdb, although my next step now is to set the symbology. I want to attempt to do this by creating a new lyrx file without an existing temp one (if possible - otherwise editing a template lyrx is an option).

I have been researching a lot but can't seem to find a direct lead on how to do it, or some say it's not possible in arcpy. I want to confirm if this is possible and if so, how to do it. Thank you!

Below is an example of what I want the output to be:


0 Kudos
1 Reply
New Contributor II

Hi Maya,

I have done something sort of similar so I can share that and it may help you. This would work really well if you have standard heatmaps that can all use a template with identical settings, but there is no reason you can't adjust things to fit a more complex arrangement.

1) Start with a .geojson file that you want to use to create a template. Bring it into ArcPro using Features to JSON tool. Symbolize the points as heatmap, picking the settings you want (e.g. Radius, Method, render quality). Once done, use Save As Layer File to create the lyrx file you will use as a template.


2) Use python code similar to below (adjust the paths) and paste it into the ArcGIS Pro Python window. This will take your .geojson file, import it into the project's geodatabase, apply symbology from the template, and save the heatmap out to a .lyrx file.

import arcpy"CURRENT")
geojsonFile = r"C:\Users\christopher.quick\Documents\ArcGIS\Projects\GeoJSON_heatmaps\SportsFields_Points.geojson"
templateFile = r"C:\Users\christopher.quick\Documents\ArcGIS\Projects\GeoJSON_heatmaps\heatmapTemplate.lyrx"
fileName = geojsonFile.split('\\')[-1].split('.')[0]
arcpy.conversion.JSONToFeatures(geojsonFile, arcpy.env.scratchWorkspace+"\{}_fromJSON".format(fileName), "POINT")"{}_fromJSON".format(fileName), templateFile)"{}_fromJSON".format(fileName), "Heatmap_{}".format(fileName),"RELATIVE")

 3) You'll have to do some testing about moving the .lyrx files around and avoiding broken links. The .lyrx is only pointing to the data so you must also provide the data itself (in your .gdb) if you want the heatmaps to show up nicely for other users.

0 Kudos