def build_url(service, baseurl=None, service_type="MapServer", layer=0, count=0):
    """
    Helper function to build valid ARCGIS url.
    """
    if baseurl is None:
        baseurl = "https://mapasinterativos.ibge.gov.br/arcgis/rest/services"
    baseurl = baseurl.rstrip("/")
    where = f"where=objectId>={count}+and+objectId<{count+1000}"
    return f"{baseurl}/{service}/{service_type}/{layer}/query?{where}&f=geojson"