CartoDB with ArcGIS API for JavaScript
When it comes to storing spatial data in the cloud, you have a handul of options. If you’re using Esri tech, there’s ArcGIS Online. Or maybe you’re rolling your own PostGIS on AWS or OpenShift or elsewhere. If you’re a fan of PostGIS, I’d highly recommend CartoDB.
CartoDB is great for storing data in a cloud-based (yeah, I said it) PostGIS service. You can upload data, query and edit, everything you’d expect. CartoDB really shines in the tools it provides that let you easily visualize your data. You don’t need to be a geo-expert to use it to make data-driven maps.
Sticking CartoDB in the ArcGIS API for JavaScript
You may be presented with a scenario where you need to get some data out of CartoDB and use it with your ArcGIS API for JavaScript application. A perfect tool for this would be to use Terraformer to convert the GeoJSON to ArcGIS Features for use in your application. If you have the resources, you may even want to create a web service in Node to proxy the requests and do the conversions for you. But if you need to stick with doing this in the browser, you can accomplish this by extending the GraphicsLayer to handle CartoDB data for you.
To do this, you’ll want to essentially have a method that does the query of the CartoDB table, parse the GeoJSON results and add the graphics the GraphicsLayer to be displayed on the map. You can accomplish that with the code below.
If you review the code, you can see it dependent on having Terraformer with the ArcGIS Parser loaded on your page. Terraformer is unfortunately not AMD compatible at the moment. Once the GeoJSON is parsed, each feature is converted to a Graphic and added to the layer.
You can see a demo of the CartoDBLayer here.
Cooking up geo-goodness
Just because you may need to work with different spatial technologies doesn’t mean you can’t get them to play well together. Because of tools like Terraformer, we can easily consume services that provide GeoJSON data and use them in our ArcGIS applications. As I mentioned earlier, you may even parse the results in a web service for your application. Maybe you’ll want to work some koop magic while your’re at it.
My point is the resources are out there and available for you to cook up as you wish the prepare a delicious geo-meal. You just may need to hack it together, but that’s okay.